<?php

class controllerClass {

    public static function get($int) {
        $sql = "SELECT * FROM  `classes` where `_id` = " . $int;
        $query = MySql::query($sql);
        while ($row = mysql_fetch_object($query)) {
            $class = new modelClass();
            return $class->deserialize($row);
        }
    }

    public static function getImage($int) {
        echo "<img width='40' height='40' src='./res/layout/";
        echo self::get($int)->image;
        echo "' title='";
        echo self::get($int)->name;
        echo "'>";
    }

    public static function getOptionList($int = null) {
        $selected = null;
        $sql = "SELECT * FROM `classes`";
        $query = MySql::query($sql);
        while ($row = mysql_fetch_object($query)) {
            if($row->_id == $int)
                $selected = "selected='selected'";
            echo "<option ".$selected." value=" . $row->_id . ">" . htmlentities($row->name) . "</option>";
        }
    }

}

?>
